import os

dataset_root = "cvpr2019_PFA/ECSSD"  # 此处使用的是ECSSD数据集，也可以换成其他的
img_list = []

def check_num_images():
    jpg_count = 0
    gt_count = 0
    for root, dirs, files in os.walk(dataset_root):
        for fname in files:
            if 'jpg' in fname:
                jpg_count += 1
                img_list.append(fname[:-4])
            if 'png' in fname:
                gt_count += 1
    print(f"num of images: {jpg_count}, num of GT maps: {gt_count}")

check_num_images()

with open("train_pair.txt", 'w+') as fout:
    for img in img_list:
        img_path = os.path.join(dataset_root, img)
        fout.write(f'{img_path}.jpg {img_path}.png\n')